{{define "Title"}}Query By Serial No.{{end}}
{{define "Content"}}

<script type=text/javascript src="/js/tablestyle.js"></script>

<div class="container-fluid">
<form class="form-horizontal" action="/queryssn" method="POST">
  <fieldset>
    <legend><b>Query By Serial No.</b></legend>
    <div class="control-group">
      <label class="control-label">Product No.&nbsp;</label>
      <div class="control">
        <input type="text" class="input-large" id="ssn" name="ssn" style="font-weight: bold; text-transform:uppercase; background-color: #FFFFD0;" maxlength="50"> <b style="color: red">*</b>
      </div>
    </div>
    <div class="form-actions">
      <button type="submit" class="btn btn-primary">Query</button>
    </div>
  </fieldset>
</form>
</div>

{{if .ssn_main.Serial}}
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Product</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_main" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>WorkOrder</th>
      <th>Item</th>
      <th>Current Station</th>
      <th>BoxID</th>
      {{if .ssn_main.CustID}}
        <th>Customer ID</th>
      {{end}}
      {{if .ssn_main.Oldssn}}
        <th>Old No.</th>
      {{end}}
      {{if .ssn_main.LinkNo}}
        <th>Bind No.</th>
      {{end}}
    </tr>
  </thead>
  <tbody>
    <tr>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.ssn_main.Serial | html}}</td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/querywo?q={{.ssn_main.Wono | html}}">{{.ssn_main.Wono | html}}</a></td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.ssn_main.Item | html}}</td>
      {{if eq .ssn_main.Curr "REPAIR"}}
        <td fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.ssn_main.Curr | html}}</td>
      {{else if eq .ssn_main.Curr "SCRAP"}}
        <td fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.ssn_main.Curr | html}}</td>
      {{else}}
        <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.ssn_main.Curr | html}}</td>
      {{end}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/querybox?q={{.ssn_main.Boxid | html}}">{{.ssn_main.Boxid | html}}</a></td>
      {{if .ssn_main.CustID}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.ssn_main.CustID | html}}</td>
      {{end}}
      {{if .ssn_main.Oldssn}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/queryssn?q={{.ssn_main.Oldssn | html}}">{{.ssn_main.Oldssn | html}}</a></td>
      {{end}}
      {{if .ssn_main.LinkNo}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/queryssn?q={{.ssn_main.LinkNo | html}}">{{.ssn_main.LinkNo | html}}</a></td>
      {{end}}
    </tr>
  </tbody>
</table>  
</div>
</div>
{{end}}

{{if .ssn_ls}}
<br/>
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Product Flow</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_ls" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>Index</th>
      <th>Station</th>
      <th>Line</th>
      <th>Result</th>
      <th>Operator</th>
	    <th>Datetime</th>
    </tr>
  </thead>
  
  <tbody>
    {{range .ssn_ls}}
    <tr>      
      {{if eq .Result "PASS" "NDF"}}        
        <td id="flow_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="flow_idx" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Index | html}}</td>
        <td id="flow_sta" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Curr | html}}</td>
        <td id="flow_lne" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Line | html}}</td>
        <td id="flow_res" fieldset style="background: #00CC00; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
        <td id="flow_opr" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Operator | html}}</td>
        <td id="flow_dat" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Date | html}}</td>
      {{else}}
        <td id="flow_ssn" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="flow_idx" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Index | html}}</td>
        <td id="flow_sta" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Curr | html}}</td>
        <td id="flow_lne" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Line | html}}</td>
        <td id="flow_res" fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
        <td id="flow_opr" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Operator | html}}</td>
        <td id="flow_dat" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Date | html}}</td>
      {{end}}
    </tr>
    {{end}}
  </tbody>
  
</table>
</div>
</div>
{{end}}

{{if .ssn_part}}
<br/>
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Product Keyparts</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_part" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>Part Name</th>
      <th>Part No</th>
      <th>Part Qty</th>
    </tr>
  </thead>
  
  <tbody>
    {{range .ssn_part}}
    <tr>
      <td id="part_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
      <td id="part_nam" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.PartName | html}}</td>
      <td id="part_pno" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/queryssn?q={{.PartId | html}}">{{.PartId | html}}</a></td>
      <td id="part_qty" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Qty | html}}</td>
    </tr>
    {{end}}
  </tbody>
  
</table>
</div>
</div>
{{end}}

{{if .ssn_fail}}
<br/>
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Repair</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_fail" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>Fail Station</th>
      <th>Fail Code</th>
      <th>Fail Description</th>
      <th>Repair Type</th>
      <th>Repair Action</th>
      <th>Repair Description</th>
    </tr>
  </thead>
  
  <tbody>
    {{range .ssn_fail}}
    <tr>
      <td id="fail_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
      <td id="fail_sta" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Station | html}}</td>
      <td id="fail_cod" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Failcode | html}}</td>
      <td id="fail_des" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Faildesc | html}}</td>
      <td id="fail_act" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RepairType | html}}</td>
      <td id="fail_act" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RepairAction | html}}</td>
      <td id="fail_rds" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RepairDesc | html}}</td>
    </tr>
    {{end}}
  </tbody>
  
</table>
</div>
</div>
{{end}}

{{if .ssn_testinfo}}
<br/>
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Testing Info</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_testinfo" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>Station</th>
      <th>Machine</th>
      <th>Testing Time</th>
      <th>Cost</th>
      <th>Program</th>
    <th>Operator</th>
    <th>Result</th>
    </tr>
  </thead>
  
  <tbody>
    {{range .ssn_testinfo}}
    <tr>
      {{if eq .Result "PASS" "NDF"}}        
        <td id="info_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="info_sta" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Station | html}}</td>
        <td id="info_mch" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.MachineId | html}}</td>
        <td id="info_tme" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TextTime | html}}</td>
        <td id="info_cst" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.EscapeTime | html}}</td>
        <td id="info_ver" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Version | html}}</td>
        <td id="info_opr" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Operater | html}}</td>
        <td id="info_rst" fieldset style="background: #00CC00; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
      {{else}}
        <td id="info_ssn" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="info_sta" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Station | html}}</td>
        <td id="info_mch" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.MachineId | html}}</td>
        <td id="info_tme" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TextTime | html}}</td>
        <td id="info_cst" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.EscapeTime | html}}</td>
        <td id="info_ver" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Version | html}}</td>
        <td id="info_opr" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Operater | html}}</td>
        <td id="info_rst" fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
      {{end}}      
    </tr>
    {{end}}
  </tbody>
  
</table>
</div>
</div>
{{end}}

{{if .ssn_testdetail}}
<br/>
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Testing Details</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_testdeta" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>Index</th>      
      <th>Station</th>
      <th>TestName</th>
      <th>Type</th>
      <th>Data</th>
      <th>Unit</th>
      <th>Lower</th>
      <th>Upper</th>
      <th>Result</th>
      <th>Datetime</th>
    </tr>
  </thead>
  
  <tbody>
    {{range .ssn_testdetail}}
    <tr>
      {{if eq .Result "PASS" "NDF"}}
        <td id="detl_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="detl_idx" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Index | html}}</td>        
        <td id="detl_sta" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Station | html}}</td>
        <td id="detl_nam" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TestName | html}}</td>
        <td id="detl_typ" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TestType | html}}</td>
        <td id="detl_dat" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TestData | html}}</td>
        <td id="detl_unt" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TestUnit | html}}</td>
        <td id="detl_low" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.LowerLimit | html}}</td>
        <td id="detl_upr" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.UpperLimit | html}}</td>
        <td id="detl_rst" fieldset style="background: #00CC00; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
        <td id="detl_dat" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Date | html}}</td>
      {{else}}
        <td id="detl_ssn" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="detl_idx" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Index | html}}</td>        
        <td id="detl_sta" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Station | html}}</td>
        <td id="detl_nam" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TestName | html}}</td>
        <td id="detl_typ" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TestType | html}}</td>
        <td id="detl_dat" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TestData | html}}</td>
        <td id="detl_unt" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TestUnit | html}}</td>
        <td id="detl_low" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.LowerLimit | html}}</td>
        <td id="detl_upr" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.UpperLimit | html}}</td>
        <td id="detl_rst" fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
        <td id="detl_dat" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Date | html}}</td>
      {{end}}
    </tr>
    {{end}}
  </tbody>
  
</table>
</div>
<span id="passivereport" style="font-size: 14px; font-weight: bold; cursor:hand; text-decoration:underline; color: #565aaa; float: left"><a href="/queryssn?prtsn={{.s_ssns | html}}" target="_blank">Report...</a></span>
</div>
{{end}}

{{if .ssn_antenna}}
<br/>
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>Test Data</b></p>
    </div>
  <div class="content-box-content">
<table id="tbl_testdeta" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>Product No.</th>
      <th>Index</th>      
      <th>TestName</th>
      <th>Frequency</th>
      <th>Ports</th>
      <th>Specification</th>
      <th>Data</th>
      <th>Result</th>
      <th>Datetime</th>
    </tr>
  </thead>
  
  <tbody>
    {{range .ssn_antenna}}
    <tr>
      {{if eq .Result "PASS" "NDF"}}        
        <td id="detl_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="detl_idx" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Index | html}}</td>
        <td id="detl_nam" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TestName | html}}</td>
        <td id="detl_fre" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Frequency | html}}</td>
        <td id="detl_por" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Ports | html}}</td>
        <td id="detl_spe" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Speci | html}}</td>
        <td id="detl_dat" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.TestData | html}}</td>
        <td id="detl_rst" fieldset style="background: #00CC00; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
        <td id="detl_dat" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Date | html}}</td>
      {{else}}
        <td id="detl_ssn" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Serial | html}}</td>
        <td id="detl_idx" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Index | html}}</td>
        <td id="detl_nam" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TestName | html}}</td>
        <td id="detl_fre" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Frequency | html}}</td>
        <td id="detl_por" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Ports | html}}</td>
        <td id="detl_spe" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Speci | html}}</td>
        <td id="detl_dat" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.TestData | html}}</td>
        <td id="detl_rst" fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Result | html}}</td>
        <td id="detl_dat" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px">{{.Date | html}}</td>
      {{end}}
    </tr>
    {{end}}
  </tbody>
</table>
</div>
<span id="antennareport" style="font-size: 14px; font-weight: bold; cursor:hand; text-decoration:underline; color: #565aaa; float: left"><a href="/queryssn?prtsn={{.s_ssns | html}}" target="_blank">Report...</a></span>
</div>
{{end}}

{{end}}